package org.graduates.webapp.actions.course;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.graduates.webapp.actions.BaseAction;
import org.projects.graduates.domain.TimeTable;

import com.opensymphony.xwork2.ActionSupport;

@Action(results = {
		@Result(name = "success", type = "json", params = {
				"includeProperties",
				"success, timeTable, timeTable.id,timeTable.version, "
						+ "timeTable.course,timeTable.course.version, timeTable.course.id" }),
		@Result(name = "input", type = "json") })
public class CommitFillInAction extends BaseAction {

	private static final long serialVersionUID = -2908518393678990192L;

	private TimeTable timeTable;

	private boolean success = false;

	public String execute() {

		if (null != timeTable) {
			if (timeTable.getContent() != null) {
				this.gradApplication.save(timeTable.getContent());
			}
			this.gradApplication.save(timeTable);
			success = true;
		} else {
			return ActionSupport.INPUT;
		}

		return ActionSupport.SUCCESS;
	}

	public TimeTable getTimeTable() {
		return timeTable;
	}

	public void setTimeTable(TimeTable timeTable) {
		this.timeTable = timeTable;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

}
